//
//  LFMineHelpController.m
//  LoveFruit
//
//  Created by xue-iOS-work on 16/9/23.
//  Copyright © 2016年 张令林. All rights reserved.
//
#import "LFMineHelpTableViewCell.h"
#import "LFMineHelpController.h"
#import "LFTempController.h"
static NSString *Cell = @"cell";
@interface LFMineHelpController ()
@property(nonatomic,strong)NSArray *array;
@property(nonatomic,strong)NSArray *subArray;
@end

@implementation LFMineHelpController
- (void)viewDidLoad {
    [super viewDidLoad];
    self.array = @[@"客服电话:",@"服务邮箱:",@"客服账户:"];
    self.subArray = @[@"400-800-8820",@"wangyi@163.com",@"先锋服务中心"];
    // 初始化导航控制器
    self.navigationItem.leftBarButtonItem = [UIBarButtonItem barBuutonItemWithTarget:self action:@selector(backItem) icon:@"btn_backItem" highlighticon:nil];
    self.navigationItem.rightBarButtonItem = [UIBarButtonItem barButtonWithTitle:nil image:@"v2_my_address_icon" style:UIBarButtonItemStylePlain target:self action:@selector(ClickRightItem:)];
    UILabel *label = [UILabel labelWithText:@"客服帮助" andTextColor:[UIColor grayColor] andFontSize:18];
    label.frame = CGRectMake(0, 0, 20, 30);
    self.navigationItem.titleView = label;
    //底部视图
    UILabel *labels = [UILabel labelWithText:@"客服时间:周一至周日9:00-20:00" andTextColor:[UIColor grayColor] andFontSize:13];
    labels.frame = CGRectMake(15, 15, 100, 30);
    self.tableView.tableFooterView = labels;
    //注册
//    [self.tableView registerClass:[LFMineHelpTableViewCell class] forCellReuseIdentifier:Cell];
    [self.tableView registerNib:[UINib nibWithNibName:@"LFMineHelpTableViewCell" bundle:nil] forCellReuseIdentifier:Cell];
}
#pragma mark - 初始化导航控制器
#pragma mark 返回按钮的点击
-(void)backItem{
    [self dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark 右边按钮的点击
-(void)ClickRightItem:(UIBarButtonItem *)sender{
    
//    LFTempController *vc = [LFTempController new];
//    //2. 设置以popover方式弹出
//    vc.modalPresentationStyle = UIModalPresentationPopover;
//    
//    //3. 获取Popover
//    UIPopoverPresentationController *popoverC = vc.popoverPresentationController;
//    
//    //4. 设置BarButtonItem属性
//    popoverC.sourceRect = CGRectMake(0, 50, popoverC.sourceView.bounds.size.width, popoverC.sourceView.bounds.size.height);
//    popoverC.barButtonItem = self.navigationItem.rightBarButtonItem;
//    
//    //5. 模态弹出
//    [self presentViewController:vc animated:YES completion:nil];
}
#pragma mark - 数据源
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.array.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    LFMineHelpTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Cell forIndexPath:indexPath];
    cell.titleLabel.text = self.array[indexPath.row];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.subTitleLabel.text = self.subArray[indexPath.row];
    return  cell;
    
}
#pragma mark - 代理
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (indexPath.row==0) {
        UIAlertView *alertView = [[UIAlertView alloc]
                                  initWithTitle:@"你敢给客服打电话?"
                                  message:@"敢打电话,我就让你关机"
                                  delegate:nil
                                  cancelButtonTitle:@"好"
                                  otherButtonTitles:nil];
        alertView.alertViewStyle = UIAlertViewStyleDefault;
        [alertView show];
    }
    
}


@end
